<div class="layui-card">
    <div class="layui-card-header">
        <h2>分配权限</h2>
    </div>
    <div class="layui-card-body">
        <form class="layui-form" action="<?php echo \yii\helpers\Url::to(['permission','id'=>$model->id])?>" method="post">
            <div class="layui-form-item">
                <label for="" class="layui-form-label">用户名</label>
                <div class="layui-form-mid layui-word-aux">
                    <?php echo $model->username; ?>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="" class="layui-form-label">邮箱</label>
                <div class="layui-form-mid layui-word-aux">
                    <?php echo $model->email; ?>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="" class="layui-form-label">权限</label>
                <div class="layui-input-block">
                    <div class="layui-form">
                        <?php foreach ($permission as $p){ ?>
                        <div class="layui-card">
                            <div class="layui-card-header">
                                <input <?php echo in_array($p['name'],array_keys($ownPermission))?'checked':'' ?> type="checkbox" name="permission[]" value="<?php echo $p['name'];?>" title="<?php echo $p['description']; ?>" lay-skin="primary" >
                            </div>
                            <?php if (isset($p['child'])&&!empty($p['child'])){ ?>
                            <div class="layui-card-body" style="margin-left:40px">
                                <?php foreach ($p['child'] as $c){ ?>
                                <input <?php echo in_array($c['name'],array_keys($ownPermission))?'checked':'' ?> type="checkbox" name="permission[]" value="<?php echo $c['name'];?>" title="<?php echo $c['description']; ?>" lay-skin="primary" >
                                <?php } ?>
                            </div>
                            <?php } ?>
                        </div>
                        <?php } ?>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button type="submit" class="layui-btn">确认</button>
                    <a href="<?php echo \yii\helpers\Url::to(['index']); ?>" class="layui-btn layui-btn-primary">返回</a>
                </div>
            </div>
        </form>
    </div>
</div>


<?php
$js = <<<JS
    layui.use(['form','element','table', 'layer'],function() {
        var form = layui.form;  
        var element = layui.element;  
        var table = layui.table;  
        var layer = layui.layer;  
        
    });
JS;
$this->registerJs($js);
